** replication file for 'Social distancing, politics and wealth'
use "replication_data_Europe_analysis.dta", clear
encode country, g(c)

* clusters:
egen clus = group(country date)

* time setting
xtset cr date

* Table 4, models 1-6

* Pooled regression
reg workplace i.c i.date L1.workplace L2.workplace L3.workplace L4.workplace  L5.workplace L6.workplace L7.workplace popu_index_standardized i.c2_workplaceclosing_recoded if weekend==0 & public_holiday==0 & date_alt!="2020-04-10" & date_alt!="2020-04-13" & date_alt!="2020-05-01" & date_alt!="2020-05-21" & date_alt!="2020-05-22" & date_alt!="2020-06-01", cluster(clus)


* Pooled regression + controls
reg workplace i.c i.date L1.workplace L2.workplace L3.workplace L4.workplace  L5.workplace L6.workplace L7.workplace popu_index_standardized i.c2_workplaceclosing_recoded ln_gdp_cap ln_pop_den under30 over70  isco_ratio if weekend==0 & public_holiday==0 & date_alt!="2020-04-10" & date_alt!="2020-04-13" & date_alt!="2020-05-01" & date_alt!="2020-05-21" & date_alt!="2020-05-22" & date_alt!="2020-06-01", cluster(clus)


* Pooled regression + controls + house prices
reg workplace  i.c i.date L1.workplace L2.workplace L3.workplace L4.workplace  L5.workplace L6.workplace L7.workplace c.popu_index_standardized i.c2_workplaceclosing_recoded ln_HP ln_gdp_cap ln_pop_den under30 over70  isco_ratio if weekend==0 & public_holiday==0 & date_alt!="2020-04-10" & date_alt!="2020-04-13" & date_alt!="2020-05-01" & date_alt!="2020-05-21" & date_alt!="2020-05-22" & date_alt!="2020-06-01", cluster(clus)


* Pooled regression + controls + employment sector
reg workplace  i.c i.date L1.workplace L2.workplace L3.workplace L4.workplace  L5.workplace L6.workplace L7.workplace popu_index_standardized i.c2_workplaceclosing_recoded ln_gdp_cap ln_pop_den under30 over70  isco_ratio pr_emp_finance_prof pr_emp_education_health pr_emp_construction pr_emp_wholesale_retail_acc pr_emp_industry if weekend==0 & public_holiday==0 & date_alt!="2020-04-10" & date_alt!="2020-04-13" & date_alt!="2020-05-01" & date_alt!="2020-05-21" & date_alt!="2020-05-22" & date_alt!="2020-06-01", cluster(clus)


* interacting with government response
reg workplace  i.c i.date L1.workplace L2.workplace L3.workplace L4.workplace  L5.workplace L6.workplace L7.workplace c.popu_index_standardized##i.c2_workplaceclosing_recoded ln_gdp_cap ln_pop_den under30 over70  isco_ratio if weekend==0 & public_holiday==0 & date_alt!="2020-04-10" & date_alt!="2020-04-13" & date_alt!="2020-05-01" & date_alt!="2020-05-21" & date_alt!="2020-05-22" & date_alt!="2020-06-01", cluster(clus)


* interacting with government response and controls + region FE
reg workplace  i.cr i.date L1.workplace L2.workplace L3.workplace L4.workplace  L5.workplace L6.workplace L7.workplace c.popu_index_standardized##i.c2_workplaceclosing_recoded c.ln_gdp_cap##i.c2_workplaceclosing_recoded c.ln_pop_den##i.c2_workplaceclosing_recoded c.under30##i.c2_workplaceclosing_recoded c.over70##i.c2_workplaceclosing_recoded  c.isco_ratio##i.c2_workplaceclosing_recoded  if weekend==0 & public_holiday==0 & date_alt!="2020-04-10" & date_alt!="2020-04-13" & date_alt!="2020-05-01" & date_alt!="2020-05-21" & date_alt!="2020-05-22" & date_alt!="2020-06-01", cluster(clus)
 
   
   
** Table A5, models 1-7
  
 * Pooled regression
reg workplace i.c i.date L1.workplace L2.workplace L3.workplace L4.workplace  L5.workplace L6.workplace L7.workplace lrscale_std i.c2_workplaceclosing_recoded if weekend==0 & public_holiday==0 & date_alt!="2020-04-10" & date_alt!="2020-04-13" & date_alt!="2020-05-01" & date_alt!="2020-05-21" & date_alt!="2020-05-22" & date_alt!="2020-06-01", cluster(clus)

* Pooled regression + controls
reg workplace i.c i.date L1.workplace L2.workplace L3.workplace L4.workplace  L5.workplace L6.workplace L7.workplace lrscale_std i.c2_workplaceclosing_recoded ln_gdp_cap ln_pop_den under30 over70  isco_ratio if weekend==0 & public_holiday==0 & date_alt!="2020-04-10" & date_alt!="2020-04-13" & date_alt!="2020-05-01" & date_alt!="2020-05-21" & date_alt!="2020-05-22" & date_alt!="2020-06-01", cluster(clus)

* Pooled regression + controls + house prices
reg workplace  i.c i.date L1.workplace L2.workplace L3.workplace L4.workplace  L5.workplace L6.workplace L7.workplace c.lrscale_std i.c2_workplaceclosing_recoded ln_HP ln_gdp_cap ln_pop_den under30 over70  isco_ratio if weekend==0 & public_holiday==0 & date_alt!="2020-04-10" & date_alt!="2020-04-13" & date_alt!="2020-05-01" & date_alt!="2020-05-21" & date_alt!="2020-05-22" & date_alt!="2020-06-01", cluster(clus)

* interacting with workplace restrictions + controls + sectoral employment
reg workplace  i.c i.date L1.workplace L2.workplace L3.workplace L4.workplace  L5.workplace L6.workplace L7.workplace lrscale_std i.c2_workplaceclosing_recoded ln_gdp_cap ln_pop_den under30 over70  isco_ratio pr_emp_finance_prof pr_emp_education_health pr_emp_construction pr_emp_wholesale_retail_acc pr_emp_industry if weekend==0 & public_holiday==0 & date_alt!="2020-04-10" & date_alt!="2020-04-13" & date_alt!="2020-05-01" & date_alt!="2020-05-21" & date_alt!="2020-05-22" & date_alt!="2020-06-01", cluster(clus)

* interacting with workplace restrictions + controls
reg workplace  i.c i.date L1.workplace L2.workplace L3.workplace L4.workplace  L5.workplace L6.workplace L7.workplace c.lrscale_std##i.c2_workplaceclosing_recoded ln_gdp_cap ln_pop_den under30 over70  isco_ratio if weekend==0 & public_holiday==0 & date_alt!="2020-04-10" & date_alt!="2020-04-13" & date_alt!="2020-05-01" & date_alt!="2020-05-21" & date_alt!="2020-05-22" & date_alt!="2020-06-01", cluster(clus)

* interacting with workplace restrictions + controls + region FE
reg workplace  i.cr i.date L1.workplace L2.workplace L3.workplace L4.workplace  L5.workplace L6.workplace L7.workplace c.lrscale_std##i.c2_workplaceclosing_recoded if weekend==0 & public_holiday==0 & date_alt!="2020-04-10" & date_alt!="2020-04-13" & date_alt!="2020-05-01" & date_alt!="2020-05-21" & date_alt!="2020-05-22" & date_alt!="2020-06-01", cluster(clus)

* interacting with workplace restrictions + controls + region FE 
reg workplace  i.cr i.date L1.workplace L2.workplace L3.workplace L4.workplace  L5.workplace L6.workplace L7.workplace c.lrscale_std##i.c2_workplaceclosing_recoded c.ln_gdp_cap##i.c2_workplaceclosing_recoded c.ln_pop_den##i.c2_workplaceclosing_recoded c.under30##i.c2_workplaceclosing_recoded c.over70##i.c2_workplaceclosing_recoded  c.isco_ratio##i.c2_workplaceclosing_recoded if weekend==0 & public_holiday==0 & date_alt!="2020-04-10" & date_alt!="2020-04-13" & date_alt!="2020-05-01" & date_alt!="2020-05-21" & date_alt!="2020-05-22" & date_alt!="2020-06-01", cluster(clus)
  

   ** Table A6, models 1-2
reg workplace  i.cr i.date L1.workplace L2.workplace L3.workplace L4.workplace  L5.workplace L6.workplace L7.workplace c.popu_index_standardized##i.c2_workplaceclosing_recoded if weekend==0 & public_holiday==0 & date_alt!="2020-04-10" & date_alt!="2020-04-13" & date_alt!="2020-05-01" & date_alt!="2020-05-21" & date_alt!="2020-05-22" & date_alt!="2020-06-01", cluster(clus)


su ln_gdp_cap, d
local p50=`r(p50)'

reg workplace  i.cr i.date L1.workplace L2.workplace L3.workplace L4.workplace  L5.workplace L6.workplace L7.workplace c.popu_index_standardized##i.c2_workplaceclosing_recoded if ln_gdp_cap>`p50' & weekend==0 & public_holiday==0 & date_alt!="2020-04-10" & date_alt!="2020-04-13" & date_alt!="2020-05-01" & date_alt!="2020-05-21" & date_alt!="2020-05-22" & date_alt!="2020-06-01", cluster(clus)

reg workplace  i.cr i.date L1.workplace L2.workplace L3.workplace L4.workplace  L5.workplace L6.workplace L7.workplace c.popu_index_standardized##i.c2_workplaceclosing_recoded if ln_gdp_cap<=`p50' & weekend==0 & public_holiday==0 & date_alt!="2020-04-10" & date_alt!="2020-04-13" & date_alt!="2020-05-01" & date_alt!="2020-05-21" & date_alt!="2020-05-22" & date_alt!="2020-06-01", cluster(clus)



  
  
** Table A7, models 1-7
* Pooled regression
reg residential i.c i.date L1.residential L2.residential L3.residential L4.residential  L5.residential L6.residential L7.residential popu_index_standardized i.c6_stayathomerequirements_re if weekend==0 & public_holiday==0 & date_alt!="2020-04-10" & date_alt!="2020-04-13" & date_alt!="2020-05-01" & date_alt!="2020-05-21" & date_alt!="2020-05-22" & date_alt!="2020-06-01", cluster(clus)

* Pooled regression + controls
reg residential i.c i.date L1.residential L2.residential L3.residential L4.residential  L5.residential L6.residential L7.residential popu_index_standardized i.c6_stayathomerequirements_re ln_gdp_cap ln_pop_den under30 over70  isco_ratio if weekend==0 & public_holiday==0 & date_alt!="2020-04-10" & date_alt!="2020-04-13" & date_alt!="2020-05-01" & date_alt!="2020-05-21" & date_alt!="2020-05-22" & date_alt!="2020-06-01", cluster(clus)

* Pooled regression + controls + house prices
reg residential  i.c i.date L1.residential L2.residential L3.residential L4.residential  L5.residential L6.residential L7.residential c.popu_index_standardized i.c6_stayathomerequirements_re ln_HP ln_gdp_cap ln_pop_den under30 over70  isco_ratio if weekend==0 & public_holiday==0 & date_alt!="2020-04-10" & date_alt!="2020-04-13" & date_alt!="2020-05-01" & date_alt!="2020-05-21" & date_alt!="2020-05-22" & date_alt!="2020-06-01", cluster(clus)

* Pooled regression + controls + employment sector
reg residential  i.c i.date L1.residential L2.residential L3.residential L4.residential  L5.residential L6.residential L7.residential popu_index_standardized i.c6_stayathomerequirements_re ln_gdp_cap ln_pop_den under30 over70  isco_ratio pr_emp_finance_prof pr_emp_education_health pr_emp_construction pr_emp_wholesale_retail_acc pr_emp_industry if weekend==0 & public_holiday==0 & date_alt!="2020-04-10" & date_alt!="2020-04-13" & date_alt!="2020-05-01" & date_alt!="2020-05-21" & date_alt!="2020-05-22" & date_alt!="2020-06-01", cluster(clus)

* interacting with residential restrictions + controls
reg residential  i.c i.date L1.residential L2.residential L3.residential L4.residential  L5.residential L6.residential L7.residential c.popu_index_standardized##i.c6_stayathomerequirements_re ln_gdp_cap ln_pop_den under30 over70  isco_ratio if weekend==0 & public_holiday==0 & date_alt!="2020-04-10" & date_alt!="2020-04-13" & date_alt!="2020-05-01" & date_alt!="2020-05-21" & date_alt!="2020-05-22" & date_alt!="2020-06-01", cluster(clus)

* interacting with residential restrictions + controls + region FE
reg residential  i.cr i.date L1.residential L2.residential L3.residential L4.residential  L5.residential L6.residential L7.residential c.popu_index_standardized##i.c6_stayathomerequirements_re if weekend==0 & public_holiday==0 & date_alt!="2020-04-10" & date_alt!="2020-04-13" & date_alt!="2020-05-01" & date_alt!="2020-05-21" & date_alt!="2020-05-22" & date_alt!="2020-06-01", cluster(clus)

* interacting with residential restrictions + controls + region FE
reg residential  i.cr i.date L1.residential L2.residential L3.residential L4.residential  L5.residential L6.residential L7.residential c.popu_index_standardized##i.c6_stayathomerequirements_re c.ln_gdp_cap##i.c6_stayathomerequirements_re c.ln_pop_den##i.c6_stayathomerequirements_re c.under30##i.c6_stayathomerequirements_re c.over70##i.c6_stayathomerequirements_re  c.isco_ratio##i.c6_stayathomerequirements_re  if weekend==0 & public_holiday==0 & date_alt!="2020-04-10" & date_alt!="2020-04-13" & date_alt!="2020-05-01" & date_alt!="2020-05-21" & date_alt!="2020-05-22" & date_alt!="2020-06-01", cluster(clus)

 
 
 
 ** Table A8, models 1-7

* Pooled regression
reg residential i.c i.date L1.residential L2.residential L3.residential L4.residential  L5.residential L6.residential L7.residential lrscale_std i.c6_stayathomerequirements_re if weekend==0 & public_holiday==0 & date_alt!="2020-04-10" & date_alt!="2020-04-13" & date_alt!="2020-05-01" & date_alt!="2020-05-21" & date_alt!="2020-05-22" & date_alt!="2020-06-01", cluster(clus)

* Pooled regression + controls
reg residential i.c i.date L1.residential L2.residential L3.residential L4.residential  L5.residential L6.residential L7.residential lrscale_std i.c6_stayathomerequirements_re ln_gdp_cap ln_pop_den under30 over70  isco_ratio if weekend==0 & public_holiday==0 & date_alt!="2020-04-10" & date_alt!="2020-04-13" & date_alt!="2020-05-01" & date_alt!="2020-05-21" & date_alt!="2020-05-22" & date_alt!="2020-06-01", cluster(clus)

* Pooled regression + controls + house prices
reg residential  i.c i.date L1.residential L2.residential L3.residential L4.residential  L5.residential L6.residential L7.residential c.lrscale_std i.c6_stayathomerequirements_re ln_HP ln_gdp_cap ln_pop_den under30 over70  isco_ratio if weekend==0 & public_holiday==0 & date_alt!="2020-04-10" & date_alt!="2020-04-13" & date_alt!="2020-05-01" & date_alt!="2020-05-21" & date_alt!="2020-05-22" & date_alt!="2020-06-01", cluster(clus)

* Pooled regression + controls + employment sector
reg residential  i.c i.date L1.residential L2.residential L3.residential L4.residential  L5.residential L6.residential L7.residential lrscale_std i.c6_stayathomerequirements_re ln_gdp_cap ln_pop_den under30 over70  isco_ratio pr_emp_finance_prof pr_emp_education_health pr_emp_construction pr_emp_wholesale_retail_acc pr_emp_industry if weekend==0 & public_holiday==0 & date_alt!="2020-04-10" & date_alt!="2020-04-13" & date_alt!="2020-05-01" & date_alt!="2020-05-21" & date_alt!="2020-05-22" & date_alt!="2020-06-01", cluster(clus)

* interacting with residential restrictions + controls
reg residential  i.c i.date L1.residential L2.residential L3.residential L4.residential  L5.residential L6.residential L7.residential c.lrscale_std##i.c6_stayathomerequirements_re ln_gdp_cap ln_pop_den under30 over70  isco_ratio if weekend==0 & public_holiday==0 & date_alt!="2020-04-10" & date_alt!="2020-04-13" & date_alt!="2020-05-01" & date_alt!="2020-05-21" & date_alt!="2020-05-22" & date_alt!="2020-06-01", cluster(clus)

* interacting with residential restrictions + controls + region FE
reg residential  i.cr i.date L1.residential L2.residential L3.residential L4.residential  L5.residential L6.residential L7.residential c.lrscale_std##i.c6_stayathomerequirements_re if weekend==0 & public_holiday==0 & date_alt!="2020-04-10" & date_alt!="2020-04-13" & date_alt!="2020-05-01" & date_alt!="2020-05-21" & date_alt!="2020-05-22" & date_alt!="2020-06-01", cluster(clus)

* interacting with residential restrictions + controls + region FE
reg residential  i.cr i.date L1.residential L2.residential L3.residential L4.residential  L5.residential L6.residential L7.residential c.lrscale_std##i.c6_stayathomerequirements_re c.ln_gdp_cap##i.c6_stayathomerequirements_re c.ln_pop_den##i.c6_stayathomerequirements_re c.under30##i.c6_stayathomerequirements_re c.over70##i.c6_stayathomerequirements_re  c.isco_ratio##i.c6_stayathomerequirements_re  if weekend==0 & public_holiday==0 & date_alt!="2020-04-10" & date_alt!="2020-04-13" & date_alt!="2020-05-01" & date_alt!="2020-05-21" & date_alt!="2020-05-22" & date_alt!="2020-06-01", cluster(clus)




 ** Figure 8
reg workplace  i.cr i.date L1.workplace L2.workplace L3.workplace L4.workplace  L5.workplace L6.workplace L7.workplace c.popu_index_standardized##i.c2_workplaceclosing_recoded c.ln_gdp_cap##i.c2_workplaceclosing_recoded c.ln_pop_den##i.c2_workplaceclosing_recoded c.under30##i.c2_workplaceclosing_recoded c.over70##i.c2_workplaceclosing_recoded  c.isco_ratio##i.c2_workplaceclosing_recoded  if weekend==0 & public_holiday==0 & date_alt!="2020-04-10" & date_alt!="2020-04-13" & date_alt!="2020-05-01" & date_alt!="2020-05-21" & date_alt!="2020-05-22" & date_alt!="2020-06-01", cluster(clus)

margins, dydx(popu_index_standardized) over(c2_workplaceclosing_recoded) saving(marginal_effects_workplace, replace)

** lrscale
reg workplace  i.cr i.date L1.workplace L2.workplace L3.workplace L4.workplace  L5.workplace L6.workplace L7.workplace c.lrscale_std##i.c2_workplaceclosing_recoded c.ln_gdp_cap##i.c2_workplaceclosing_recoded c.ln_pop_den##i.c2_workplaceclosing_recoded c.under30##i.c2_workplaceclosing_recoded c.over70##i.c2_workplaceclosing_recoded  c.isco_ratio##i.c2_workplaceclosing_recoded if weekend==0 & public_holiday==0 & date_alt!="2020-04-10" & date_alt!="2020-04-13" & date_alt!="2020-05-01" & date_alt!="2020-05-21" & date_alt!="2020-05-22" & date_alt!="2020-06-01", cluster(clus)

margins, dydx(lrscale_std) over(c2_workplaceclosing_recoded) saving(marginal_effects_workplace_lrscale, replace)

use "marginal_effects_workplace.dta", clear
replace _deriv=0
append using "marginal_effects_workplace_lrscale.dta"
drop if _by1==0
replace _by1=.1 if _by1==0 & _deriv==1
replace _by1=1.1 if _by1==1 & _deriv==1
replace _by1=2.1 if _by1==2 & _deriv==1
replace _by1=3.1 if _by1==3 & _deriv==1
replace _by1=4.1 if _by1==4 & _deriv==1

twoway  rspike _ci_lb _ci_ub _by1 if _deriv==0,  scheme(plotplain) lcolor(black) lwidth(medthick) || ///
		rspike _ci_lb _ci_ub _by1 if _deriv==1,  lcolor(gray)  lwidth(medthick)  || ///
scatter _margin _by1 if _deriv==0, msym(O) msize(large) mlwidth(medthick) mlcolor(black) mfcolor(black) || ///
scatter _margin _by1 if _deriv==1, msym(O) msize(large) mlwidth(medthick) mlcolor(gray) mfcolor(white) ///
yline(0) ylab(-2(1)3,  labsize(small)) yticks(-2(1)3) xtitle("")  ///
xlab(1.05 `""No measures -" "from June 1""' ///
 2.05 `""Closing/" "work from home" "recommended""' ///
 3.05 `""Closing/" "work from home" "required for some" "sectors/workers""' ///
 4.05 `""Closing/" "work from home" "required for all but" "essential workplaces""', labsize(small) nogrid) ///
ytitle("Effect size", size(medsmall)) /// 
legend( order(3 4) label(3 "PRR sentiments") label(4 "Left-right ideology") size(medsmall) pos(4)) xsize(7) 




* Figure A6
reg residential  i.cr i.date L1.residential L2.residential L3.residential L4.residential  L5.residential L6.residential L7.residential c.popu_index_standardized##i.c6_stayathomerequirements_re c.ln_gdp_cap##i.c6_stayathomerequirements_re c.ln_pop_den##i.c6_stayathomerequirements_re c.under30##i.c6_stayathomerequirements_re c.over70##i.c6_stayathomerequirements_re  c.isco_ratio##i.c6_stayathomerequirements_re  if weekend==0 & public_holiday==0 & date_alt!="2020-04-10" & date_alt!="2020-04-13" & date_alt!="2020-05-01" & date_alt!="2020-05-21" & date_alt!="2020-05-22" & date_alt!="2020-06-01", cluster(clus)

margins, dydx(popu_index_standardized) over(c6_stayathomerequirements_re) saving(marginal_effects_residential, replace)

** lrscale
reg residential  i.cr i.date L1.residential L2.residential L3.residential L4.residential  L5.residential L6.residential L7.residential c.lrscale_std##i.c6_stayathomerequirements_re c.ln_gdp_cap##i.c6_stayathomerequirements_re c.ln_pop_den##i.c6_stayathomerequirements_re c.under30##i.c6_stayathomerequirements_re c.over70##i.c6_stayathomerequirements_re  c.isco_ratio##i.c6_stayathomerequirements_re  if weekend==0 & public_holiday==0 & date_alt!="2020-04-10" & date_alt!="2020-04-13" & date_alt!="2020-05-01" & date_alt!="2020-05-21" & date_alt!="2020-05-22" & date_alt!="2020-06-01", cluster(clus)

margins, dydx(lrscale_std) over(c6_stayathomerequirements_re) saving(marginal_effects_residential_lrscale, replace)
 

use "marginal_effects_residential.dta", clear
replace _deriv=0
append using "marginal_effects_residential_lrscale.dta"
drop if _by1==0
replace _by1=.1 if _by1==0 & _deriv==1
replace _by1=1.1 if _by1==1 & _deriv==1
replace _by1=2.1 if _by1==2 & _deriv==1
replace _by1=3.1 if _by1==3 & _deriv==1
replace _by1=4.1 if _by1==4 & _deriv==1

twoway  rspike _ci_lb _ci_ub _by1 if _deriv==0,  scheme(plotplain) lcolor(black) lwidth(medthick) || ///
		rspike _ci_lb _ci_ub _by1 if _deriv==1,  lcolor(gray)  lwidth(medthick)  || ///
scatter _margin _by1 if _deriv==0, msym(O) msize(large) mlwidth(medthick) mlcolor(black) mfcolor(black) || ///
scatter _margin _by1 if _deriv==1, msym(O) msize(large) mlwidth(medthick) mlcolor(gray) mfcolor(white) ///
yline(0) ylab(-1(0.5)1,  labsize(small)) yticks(-1(0.5)1) xtitle("")  ///
xlab(1.05 `""No measures -" "from March 31""' ///
 2.05 `""Stay at home" "recommended""' ///
 3.05 `""Stay at home" "required with" "some exceptions""' ///
 4.05 `""Stay at home" "required with" "minimal exceptions""', labsize(small) nogrid) ///
ytitle("Effect size", size(medsmall)) /// 
legend( order(3 4) label(3 "PRR sentiments") label(4 "Left-right ideology") size(medsmall) pos(4)) xsize(7) 

